package com.tbit.main.service;

import com.tbit.main.pojo.*;
import com.tbit.main.pojo.VO.WorkOrderCountRespVO;
import com.tbit.main.pojo.VO.WorkOrderQueryReqVO;

import java.util.List;

/**
 * @author LMY
 * @create 2021-05-18 15:38
 * 工单
 */
public interface WorkOrderService {

    /**
     * 创建工单
     *
     * @param workOrder
     */
    void insert(WorkOrder workOrder);

    /**
     * 根据工单编号查询
     *
     * @param workOrderId
     * @return
     */
    WorkOrder getByWorkOrderId(String workOrderId);

    /**
     * 根据工单单号批量查询
     *
     * @param workOrderIds
     * @return
     */
    List<WorkOrder> getByWorkOrderIds(List<String> workOrderIds);

    /**
     * 根据用户和时间查询工单
     *
     * @return
     */
    List<WorkOrder> getByUserId(Integer accountId, AccountUser accountUser, Integer accountUserId, String startTime, String endTime,
                                Integer state, Integer workType, Integer isValid, List<Integer> regionId, Integer assign, Integer machineType, Integer buildType, Integer pageNO, Integer rowCount, Integer locationType);

    /**
     * 修改工单状态
     *
     * @param workOrderId
     * @param accountUserId
     * @param state
     */
    void updateState(String workOrderId, Integer accountUserId, String UserName, Integer businessNO, Integer state, Integer isValid);

    /**
     * 查询完成工单总数
     *
     * @param accountId
     * @param accountUserId
     * @param state
     * @param workType
     * @param startTime
     * @param endTime
     * @return
     */
    Integer getByUserIdCount(Integer accountId, AccountUser accountUser, Integer accountUserId, String startTime, String endTime,
                             Integer state, Integer workType, Integer isValid, List<Integer> regionId, Integer assign, Integer machineType, Integer buildType, Integer locationType);

    /**
     * 开始判断工单权限
     *
     * @param workType
     * @param accountUser
     * @param machine
     */
    void startWork(Integer workType, AccountUser accountUser, Machine machine);

    /**
     * 结束添加工单记录
     *
     * @param workType
     * @param accountUser
     * @param machineId
     * @param businessNO
     * @param isValid
     */
    void endWork(Integer workType, AccountUser accountUser, Integer machineId, Integer businessNO, Integer isValid, String redisKey, Integer state);

    /**
     * 更新超时，失效
     *
     * @param workOrderIds
     * @param state
     */
    void updateTime(List<String> workOrderIds, Integer state);

    /**
     * 人员工单类型分组
     *
     * @return
     */
    List<WorkOrderSta> getGroupByUserId(Integer accountId, Integer userType, Integer accountUserId,
                                        String startTime, String endTime, Integer workType,
                                        List<Integer> regionId, Integer buildType, Integer locationType);

    /**
     * 删除
     *
     * @param workOrderId
     */
    void del(String workOrderId);

    /**
     * 未完成工单分组
     *
     * @param accountId
     * @param accountUserToken
     * @param regionId
     * @return
     */
    List<WorkOrderTypeSta> getGroupByType(Integer accountId, AccountUser accountUserToken, List<Integer> regionId);

    /**
     * 更新
     *
     * @param workOrder
     */
    void update(WorkOrder workOrder);

    /**
     * 获得所有工单列表
     * @param reqVO 请求参数
     * @return 工单列表
     */
    List<WorkOrder> getWorkOrderList(WorkOrderQueryReqVO reqVO);

    /**
     * 统计工单数量
     *
     * @param workOrderCountAll 全部运维
     * @param workOrders        工单列表
     * @return 工单数量
     */
    WorkOrderCountRespVO getWorkOrderCount(WorkOrderCountRespVO workOrderCountAll, List<WorkOrder> workOrders);

    /**
     * 将当前记录置为无效
     * @param businessNOList 当前工单业务记录
     * @param isValid 是否有效
     * @param state 工单状态
     * @param remark 备注
     */
    void updateAuditToInvalidByBusinessNOList(List<Integer> businessNOList, Integer isValid, Integer state, String remark);

    /**
     * 根据业务类型编号查询
     * @param businessNOList 业务编号
     * @return 工单列表
     */
    List<WorkOrder> getByBusinessNOList(List<Integer> businessNOList);
}
